# Maintainer: Anatol Pomozov <anatol.pomozov@gmail.com>
# Maintainer: Eric Biggers <ebiggers3 at gmail dot com>

pkgname=fscrypt
pkgver=0.3.4
pkgrel=1
pkgdesc='A tool for managing Linux filesystem encryption'
arch=('loong64' 'x86_64')
url='https://github.com/google/fscrypt'
license=('Apache')
makedepends=('go')
depends=('pam')
source=("fscrypt-$pkgver.zip::https://github.com/google/fscrypt/archive/v$pkgver.zip"
        "pam_config")
sha512sums=('d12a9a06d4ede7f01cafc2b807eed769b76f192d011ea4a9252f25e69f18d43f0f5dcb199e523f3f2b2701ea7fcdde378343435ec023ccd267f28ab8fd17417b'
            '56f443cd2fbed9c164693c800cd8dc08bb35b88bb9c912fb35eb43cc6c6bc3b966d22d9810f43580d12b9faa8d753419a06336f08c47a0e602c48a103a705299')

build() {
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"

  cd "fscrypt-$pkgver"
  BUILDDATE="`date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}"`" make
}

package() {
  cd "fscrypt-$pkgver"
  make PREFIX="${pkgdir}/usr" install
  install -Dm644 ../pam_config "${pkgdir}/etc/pam.d/fscrypt"
  install -Dm644 -t "$pkgdir/usr/share/licenses/fscrypt/" LICENSE

  # Remove Ubuntu-specific PAM file
  rm -r "$pkgdir"/usr/share/pam-configs/
}
